package com.xsqf.jt808.common.vo.req.terminal;

import com.xsqf.jt808.common.vo.DataPacket;
import io.netty.buffer.ByteBuf;
import lombok.Data;

/**
 * @Author:
 * @Date: 2020-5-14
 * @Description:终端注册包
 * @Version: 1.0
 */
@Data
public class RegisterMsg extends DataPacket {

    private Short provinceId;//省域ID 2字节
    private Short cityId;//市县ID 2字节
    private String manufacturerId;//制造商ID 5字节
    private String terminalType;//终端型号 8字节
//    private String terminalId;//终端SIM卡号
    private String terminalNumber;//终端ID，由制造商自己定义 7字节
    private Byte licensePlateColor;//车牌颜色 1字节
    private String licensePlate;//车牌号 剩余字节

    public RegisterMsg(ByteBuf byteBuf) {
        super(byteBuf);
    }

    @Override
    public void parseBody() {
        ByteBuf bb = this.payload;
        this.setProvinceId(bb.readShort());
        this.setCityId(bb.readShort());
        this.setManufacturerId(readString(5));
        this.setTerminalType(readString(20));
        this.setTerminalNumber(readString(7));
        this.setLicensePlateColor(bb.readByte());
        this.setLicensePlate(readString(bb.readableBytes()));
    }
}
